<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>无标题文档</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="layui/css/layui.css"  media="all">
<link rel="stylesheet" href="layui/css/layui.mobile.css"/>
<script src="js/jquery3.3.1.min.js"></script>
<script src="layui/layui.all.js"></script>
<script src="layui/layui.js"></script>
<script type="text/javascript">
$(document).ready(function(){
  $(".click").click(function(){
  $(".tip").fadeIn(200);
  });
	
  
  $(".tiptop a").click(function(){
  $(".tip").fadeOut(200);
});

  $(".sure").click(function(){
  $(".tip").fadeOut(100);
});

  $(".cancel").click(function(){
  $(".tip").fadeOut(100);
});



});
function selectAll(){
    if ($("#SelectAll").is(":checked")) {
        $(":checkbox").prop("checked", true);//所有选择框都选中
    } else {
        $(":checkbox").prop("checked", false);
    }
}
function typeDeletes(){
    //判断至少写了一项
    var checkedNum = $("input[name='subcheck']:checked").length;
    if(checkedNum==0){
        alert("请至少选择一项!");
        return false;
    }
    var result="";
    var count=0;
    $(".checkb").each(function(){
        if($(this).is(':checked')){
            result+=$(this).val()+",";
            count++;
        }else{}
    });
    if(!confirm("确定删除这"+count+"个游戏?")){
        return;
    }
    window.location.href= "/gametypeDeletes?tag="+result;}



function showtype(){
    //异步查询出数据,当ajax请求的网址响应返回后，会自动回调匿名函数

    //负责显示窗口
    var	layer = layui.layer;
    var othis = $(this);

    var type = othis.data('type')
    var text = othis.text();
    layer.open({
        type: 1
        ,skin:'layui-layer-molv'
        ,offset:type
        ,id: 'layerDemo'+type //防止重复弹出
        ,content: $(".form2")
        ,btnAlign: 'c' //按钮居中
        ,shade: 0.5 //不显示遮罩
        ,title:"添加游戏类型"
        ,area:['700px','500px']
        ,yes: function(index, layero){
            layer.close(index);
        },
        btn2: function(index, layero){
            $(".form1").submit();
        },
        end:function(){
            $(".form2").hide();
        }
    });
}

function editgametype(typeid){
    //异步查询出数据,当ajax请求的网址响应返回后，会自动回调匿名函数
    $.post("/editgametype",{"typeid":typeid},function(data){
        $("#typeid").val("");
        $("#typename").val("");
        $("#typeid").val(data.typeid);

        $("#typename").val(data.typename);
        $("#status").val("");
        $("#status").val(data.typestatus);

    })
    //负责显示窗口
    var	layer = layui.layer;
    var othis = $(this);
    var type = othis.data('type')
    var text = othis.text();
    layer.open({
        type: 1
        ,skin:'layui-layer-molv'
        ,offset:type
        ,id: 'layerDemo'+type //防止重复弹出
        ,content: $(".form4")
        ,btnAlign: 'c' //按钮居中
        ,shade: 0.5 //不显示遮罩
        ,title:"修改游戏类型"
        ,area:['700px','500px']
        ,yes: function(index, layero){
            layer.close(index);
        },
        btn2: function(index, layero){
            $(".form3").submit();
        },
        end:function(){
            $(".form4").hide();
        }
    });
}

</script>


</head>


<body>

	<div class="place">
    <span>位置：</span>
    <ul class="placeul">
    <li><a href="#">首页</a></li>
    <li><a href="#">游戏管理</a></li>
    </ul>
    </div>

<div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
  <ul class="layui-tab-title">
    <li class="layui-this">游戏类型管理</li>

  </ul>
  <div class="layui-tab-content">
    <!--游戏类型管理-->
    <div class="layui-tab-item layui-show">
    <div class="rightinfo">
    <div class="tools">
    	<ul class="toolbar">
        <li onclick="showtype()"><span><img src="images/t01.png" /></span>添加</li>
        <li onclick="typeDeletes()"><span><img src="images/t03.png" /></span>删除</li>
        </ul>
    </div>
	<table class="tablelist">
    	<thead>
    	<tr>
        <th ><input onclick="selectAll()" id="SelectAll"  name="" type="checkbox" value="" /></th>
        <th>类型ID</th>
        <th>类型名称</th>
        <th>禁用状态</th>
        <th>操作</th>
        </tr>
        </thead>
        <tbody class="list">
        <c:forEach items="${typePageInfo.list}" var="type">
        <tr>
        <td><input class="checkb" id="subcheck" name="subcheck" type="checkbox" value="${type.typeid}" /></td>
        <td>${type.typeid}</td>
        <td>${type.typename}</td>
            <c:choose>
            <c:when test="${type.typestatus==2}"><td>禁用</td></c:when>
            <c:otherwise><td>启用</td></c:otherwise>
            </c:choose>
        <td><a  onclick="editgametype(${type.typeid})" name="typeid" class="tablelink" href="#">编辑</a>
            <a href="/deltype?typeid=${type.typeid}" class="tablelink"> 删除</a></td>
        </tr>
        </c:forEach>
     </tbody>
    </table>
    <div class="pagin">
        <div class="message">共<i class="blue">${typePageInfo.total}</i>条记录，当前显示第&nbsp;<i class="blue">${typePageInfo.pageNum}&nbsp;</i>页</div>
        <ul class="paginList">
            <li class="paginItem current"><a href="gametype?pageNum=1">首页</a></li>
            <c:choose>
                <c:when test="${typePageInfo.isFirstPage}">
                    <li class="paginItem"><a href="#"><span class="pagepre"></span></a></li>
                </c:when>
                <c:otherwise>
                    <li class="paginItem"><a href="gametype?typePageNum=${typePageInfo.prePage}"><span class="pagepre"></span></a></li>
                </c:otherwise>
            </c:choose>
            <li class="paginItem current"><a href="javascript:;">${typePageInfo.pageNum}</a></li>
            <c:choose>
                <c:when test="${typePageInfo.isLastPage}">
                    <li class="paginItem"><a href="#"><span class="pagenxt"></span></a></li>
                </c:when>
                <c:otherwise>
                    <li class="paginItem"><a href="gametype?typePageNum=${typePageInfo.nextPage}"><span class="pagenxt"></span></a></li>
                </c:otherwise>
            </c:choose>
            <li class="paginItem current"><a href="gametype?pageNum=${typePageInfo.pages}">尾页</a></li>
        </ul>
    </div>
        <%--添加游戏类型--%>
        <div class="form2" style="padding:20px 20px;display: none;">
            <form class="layui-form form1" action="/addGameType" method="post">
                <div class="layui-form-item">
                    <label class="layui-form-label">类型名称</label>
                    <div class="layui-input-inline">
                        <input type="text" name="typename"  required lay-verify="required" placeholder="请输入类型名称" autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux"></div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">状态</label>
                    <div class="layui-input-block">
                        <input type="radio" name="typestatus" value="1" title="启用">
                        <input type="radio" name="typestatus" value="2" title="禁用" checked>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn"  lay-filter="formDemo" style="background-color:#4098CA" >立即提交</button>
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </div>
                </div>
            </form>
        </div>
        <%--修改游戏类型--%>
        <div class="form4" style="padding:20px 20px;display: none;">
            <form class="layui-form form3" action="changegametype">
                <div class="layui-form-item">
                    <label class="layui-form-label">游戏类型ID</label>
                    <div class="layui-input-block">
                        <input readonly  unselectable="on"  style="width:50px;" type="text" name="typeid" id="typeid" required  lay-verify="required" placeholder="游戏类型ID" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">游戏类型名称</label>
                    <div class="layui-input-inline">
                        <input type="text" name="typename" id="typename" required lay-verify="required" placeholder="请输入游戏类型名称" autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux"></div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">状态</label>
                    <div class="layui-input-block">
                        <input type="radio" name="typestatus" value="1" title="启用">
                        <input type="radio" name="typestatus" value="2" title="禁用" checked>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-filter="formDemo" style="background-color:#4098CA" >立即提交</button>
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </div>
                </div>
            </form>
        </div>


        <script>
            //Demo
            layui.use('form', function(){
                var form = layui.form;

                //监听提交
                form.on('submit(formDemo)', function(data){
                    layer.msg(JSON.stringify(data.field));
                    return false;
                });
            });
        </script>
  </div></div>

  </div>
</div>

</body>

</html>
